package de.hwrberlin.remo.diagram.custom.actions;

import org.apache.log4j.Logger;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;

import de.hwrberlin.expertsystem.util.ModelEditingHelper;
import de.hwrberlin.remo.algorithm.UserInterface;
import de.hwrberlin.remo.diagram.custom.util.DiagramEditorUserInterface;

public class ResetRulesAction extends AbstractRemoDiagramAction {

	@Override
	public void run(IAction action) {
		Logger logger = Logger.getLogger(getClass().getName());
		
		ModelEditingHelper editingHelper = new ModelEditingHelper(expertSystemEditor.getEditingDomain());
		UserInterface visualisationHelper = new DiagramEditorUserInterface(expertSystemEditor);

		logger.info("Resetting all rules");
		editingHelper.resetRules(knowledgeBase);
		visualisationHelper.unhighlightAllElement(knowledgeBase.getOwnedElements());
		
		expertSystemEditor.doSave(new NullProgressMonitor());
	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
		// Do nothing
	}
}